<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // ES5
    var name = "张三";
    var age = 18;
    var height = "176cm";
    var weight = "72kg";

    // 把变量放到对象中作为对象的属性
    var zhang = {
        // 键名:键值(变量名)
        name: name,
        age: age,
        height: height,
        weight: weight,
        say: function () {
            console.log(this.name, this.age);
        }
    }
    console.log(zhang);


    // ES6 简写
    // 1. 对象中键名和键值对应的变量相同时可以简写
    // 2. 对象中函数可以简写 => 省略:function
    var zhang = {
        name,
        age,
        height,
        weight,
        say() {
            console.log(this.name, this.age);
        }
    }
    console.log(zhang);
    console.log(zhang.say);

    zhang.say();





</script>

</html>